package com.example.foo.member.service;

import com.example.core.PageResult;
import com.example.core.Pageable;
import com.example.foo.member.dao.AdressManageDao;
import com.example.foo.member.model.AdressManage;
import com.example.foo.member.query.AdressManageQuery;

import java.time.LocalDateTime;
import java.util.List;

@org.springframework.stereotype.Service
public class AdressManageService {

    private final AdressManageDao adressManageDao;

    public AdressManageService(AdressManageDao adressManageDao) {
        this.adressManageDao = adressManageDao;
    }

    // ========== AdressManage ==========

    public PageResult<AdressManage> findAdressManages(AdressManageQuery adressManageQuery, Pageable pageable) {
        return adressManageDao.findAdressManages(adressManageQuery, pageable);
    }

    public List<AdressManage> findAdressManagesByIds(List<Long> ids) {
        return adressManageDao.selectBatchIds(ids);
    }

    public AdressManage findAdressManageById(Long id) {
        return adressManageDao.selectById(id);
    }

    public void createAdressManage(AdressManage adressManage) {
        adressManage.setCreatedAt(LocalDateTime.now());
        adressManageDao.insert(adressManage);
    }

    public void updateAdressManage(AdressManage adressManage) {
        adressManage.setUpdatedAt(LocalDateTime.now());
        adressManageDao.updateById(adressManage);
    }

    public void deleteAdressManageById(Long id) {
        adressManageDao.deleteById(id);
    }
}
